﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GSI.Core
{

	/// <summary>
	/// 普通数据集合
	/// </summary>
	class DataGroup
	{
		public double MaxX { get; private set; }
		public double MaxY { get; private set; }
		public double MinX { get; private set; }
		public double MinY { get; private set; }
		public double SpanX { get; private set; }
		public double SpanY { get; private set; }
		public double MaxValue { get; private set; }
		public double MinValue { get; private set; }
		public double SpanValue { get; private set; }

		public List<GPoint> Points { get; set; }
		/// <summary>
		/// 初始化网格最值
		/// </summary>
		public void Init()
		{
			MaxX = 0;
			MaxY = 0;
			MaxValue = 0;
			MinX = Points[0].X;
			MinY = Points[0].Y;
			MinValue = Points[0].Value;
			for (int i = 0; i < Points.Count; i++)
			{
				MaxX = Math.Max(Points[i].X, MaxX);
				MinX = Math.Min(Points[i].X, MinX);

				MaxY = Math.Max(Points[i].Y, MaxY);
				MinY = Math.Min(Points[i].Y, MinY);

				MaxValue = Math.Max(Points[i].Value, MaxValue);
				MinValue = Math.Min(Points[i].Value, MinValue);
			}
			SpanX = MaxX - MinX;
			SpanY = MaxY - MinY;
			SpanValue = MaxValue - MinValue;
		}

		private void GetM(ref double Max,ref double Min,double a,double b)
		{
			if (a < b)
			{
				var tmp = a;
				a = b;
				b = a;
			}
			Max = Math.Max(a, Max);
			Min = Math.Min(b, Min);
		}
	}
}